<?php
/**
 * Created by JetBrains PhpStorm.
 * User: h2a!
 * Date: 21/11/2012
 * Time: 21:40
 * To change this template use File | Settings | File Templates.
 */

Class Manage_Product_Model extends CI_Model{
    //get all products
    public function  get_all_products() {
        $this->load->database();
        $query = $this->db->get('bh_product');
        return $query->result();
    }

    //get data of a product
    public function get_product($id = 0) {
        $this->load->database();
        $query = $this->db->get_where('bh_product',array('product_id' => $id));
        return $query->row_array();
    }


//    public function get_product($id = 0) {
//        $this->db->select('product_id');
//        $this->db->where('product_id', $id);
//        $query = $this->db->get('bh_product');
//        return $query->result_array();
//    }

    //insert a product
    public function insert_product($data) {
        $this->db->insert('bh_product',$data);
    }

    public function edit_product($data, $id) {
        $this->load->database();
        $this->db->where('product_id',$id);
        $this->db->update('bh_product',$data);
    }

    //delete a product
    public  function delete_product($id) {
        $this->db->delete('bh_product', array('product_id' => $id));
    }
}
?>